#define _CRT_SECURE_NO_WARNINGS 1


#include<iostream>

using namespace std;

int Func(int n)
{
	int sum = 0;

	while (n)
	{
		if (n % 10 == 2)
		{
			sum++;
		}

		n /= 10;
	}

	return sum;
}

int main()
{
	int n = 0, m = 0;
	cin >> n >> m;

	int sum = 0;
	for (int i = n; i <= m; i++)
	{
		sum += Func(i);
	}

	cout << sum << endl;

	return 0;
}